export default {
	getColumns() {
		//获取安全问题标签 columns
		return this.getSafeData()
	},
	async getNoteList(params) {
		let _push_form = {}
		_push_form.estateId = params.partId
		_push_form.partId = params.partId
		_push_form.statusList = params.statusList
		const data = await uni.$H.get('/estateChronicleEvent/getList', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			return false
		} else {
			return data.body
		}
	},
	async getSafeData() {
		// /faultCategory/getAll
		const data = await uni.$H.get('/faultCategory/getAll', {}, {
			authCode: true
		})
		if (data.status === 0) {
			return data.body.filter(item => item.faultLevel == 1 && item.faultType == 2, )
		}
	},
	async getQualityData() {
		// /faultCategory/getAll
		const data = await uni.$H.get('/faultCategory/getAll', {}, {
			authCode: true
		})
		if (data.status === 0) {
			return data.body.filter(item => item.faultLevel == 1 && item.faultType == 1, )
		}
	},
	async getchild(id) {
		const data = await uni.$H.get('/faultCategory/getByParentId', {
			parentId: id,
			type: 2
		}, {
			authCode: true
		})
		if (data.status === 0) {
			// if(data.body != [])
			return data.body
		}
	},
	async getChildData() {
		let f = await this.getSafeData()
		console.log(f)
		let nn = []
		for (let i = 0; i < f.length; i++) {
			nn.push(await this.getchild(f[i].faultId))
		}
		console.log(nn)
		return nn
	},
	async getSelectNode(para) {
		const {
			data
		} = await uni.$http.get(uni.$http.baseURL +
			"/realEstatePart/getPartInfoByParentIdAndEstateId", {
				parentId: para.id,
				estateId: para.estateId,
			}
		);
		if (data.status === 0) {
			if (data.body.length != 0) {
				return data.body;
			} else {
				// uni.$showMsg("请先绑定地产检查项信息");
				return []
			}
		} else {
			uni.$showMsg(data.message);
			return []
		}
	},
	// async getSelecHouseNode(id) {
	// 	const {
	// 		data
	// 	} = await uni.$http.get(uni.$http.baseURL +
	// 		"/realEstatePart/getPartInfoByParentIdAndEstateId", {
	// 			parentId: id,
	// 			estateId: uni.getStorageSync("houseId"),
	// 		}
	// 	);
	// 	if (data.status === 0) {
	// 		if (data.body.length != 0) {
	// 			return data.body;
	// 		} else {
	// 			// uni.$showMsg("请先绑定地产检查项信息");
	// 			return []
	// 		}
	// 	} else {
	// 		uni.$showMsg(data.message);
	// 		return []
	// 	}
	// },
	async getHouseList() {
		const data = await uni.$H.post(
			"/userEstateMap/getByQuery", {
				roleId: "4",
				userId: uni.getStorageSync("userId"),
				estateType: 1,
			}, {
				authCode: true,
			}
		);
		if (data.status === 0) {
			return data.body
		} else {
			uni.$showMsg(data.message);
			return []
		}
	},

	async getHouseNodeColumns() {
		let tempList = await this.getHouseList()
		console.log(tempList)
		let temp = []
		for (let i = 0; i < tempList.length; i++) {
			let item = tempList[i].realEstateVO
			item.partId = tempList[i].realEstateVO.estateId
			item.partName = tempList[i].realEstateVO.building + '栋' + tempList[i].realEstateVO.unit + '单元' +
				tempList[i]
				.realEstateVO.num + '号'
			temp.push(item)
		}
		console.log(temp)
		return temp
	},
	async getAllProject() {
		const data = await uni.$H.get("/developer/getProjectList", {}, {
			authCode: true,
		})
		if (data.status === 0) {
			return data.body
		} else {
			uni.$showMsg(data.message);
			return []
		}
	},
	// 
	async getByParent(id) {
		const {
			data
		} = await uni.$http.get(uni.$http.baseURL + "/realEstatePart/getByParent", {
			parentId: id
		})
		if (data.status === 0) {
			return data.body
		} else {
			uni.$showMsg(data.message);
			return []
		}
	},

}
